<?php 

namespace app\controller\bossManager;

use app\service\AppInfoTableService;
use app\validate\AppInfoTableValidate;
use app\validate\PageValidate;
use share\utils\Helper;

class AppInfoController extends WebBossController{

    public function initValidate(){
        $this->validate = new AppInfoTableValidate();
    }

    public function list_action(){
        $param = $this->request->param();
        $page = $this->check('pageInfo',null,(new PageValidate()));
        $data = AppInfoTableService::getListInfo($param,$page);
        foreach($data as &$d){
            if(strlen($d['module']) > 1){
                $d['module'] = @json_decode($d['module'],true);
            } 
        }
        $total = AppInfoTableService::getListCountInfo($param);
        return self::ok(self::formatPageData($page,$total,$data));
    }

    public function simple_all_action(){      
        $data = AppInfoTableService::getAllByFilter([]);
        return self::ok(Helper::pickArrayColumn($data,['id','package','vendor','vendor_name']));
    }

}
